package com.qst.Serviceimpl;

import com.qst.Service.LoginuserService;
import com.qst.dao.LoginuserMapper;
import com.qst.pojo.Admin;
import com.qst.pojo.Room;
import com.qst.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jws.soap.SOAPBinding;
import java.sql.SQLException;
import java.util.List;

/**
 * @packageName:com.qst.Serviceimpl
 * @className:LoginuserServiceimpl
 * @Description:
 * @author:zhangyu
 * @date 2021/6/17 18:47
 **/

@Service
public class LoginuserServiceimpl implements LoginuserService {


    @Autowired
    private LoginuserMapper loginuserMapper;

    @Override
    public Boolean finduser(String loginname, String password) {
        User loginUser = null;
        try {
            loginUser = loginuserMapper.getuser(loginname);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        if(loginUser!=null && loginUser.getPassword().equals(password)){
            return true;
        }else{
            return false;
        }
    }


//    @Override
//    public User finduser(String loginname, String password) {
//        try {
//            User user =  loginuserMapper.getuser(loginname);
//            return user;
//        } catch (SQLException throwables) {
//            throwables.printStackTrace();
//        }
//        return null;
//    }

    @Override
    public Boolean getaminbyname(String loginname, String password) {
        Admin admin = null;
        try {
            admin = loginuserMapper.getaminbyname(loginname);
        } catch (Exception throwables) {
            throwables.printStackTrace();
        }
        if(admin!=null && admin.getPassword().equals(password)){
            return true;
        }else{
            return false;
        }
    }



    @Override
    public List<User> getuserbyname(String loginname) {
        List<User> users = loginuserMapper.getuserbyname(loginname);
        return users;
    }
}
